
/*
 * Copyright 2002-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2017原作者。
 *
 *根据Apache许可证2.0版许可（“许可证”）；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本：
 *
 *https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证进行的分发是在“按原样”的基础上进行的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证和
 *许可证下的限制。
 */

package org.springframework.jmx.export.metadata;

import org.springframework.jmx.support.MetricType;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

/**
 * Metadata that indicates to expose a given bean property as a JMX attribute,
 * with additional descriptor properties that indicate that the attribute is a
 * metric. Only valid when used on a JavaBean getter.
 *
 * @author Jennifer Hickey
 * @since 3.0
 * @see org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler
 */
/**
 *指示将给定bean属性公开为JMX属性的元数据，
 *具有额外的描述符属性，这些属性指示该属性是
 *公制。仅在JavaBean getter上使用时有效。
 *
 *@作者詹妮弗·希基
 *@自3.0起
 *@参见org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler
 */
public class ManagedMetric extends AbstractJmxAttribute {

	@Nullable
	private String category;

	@Nullable
	private String displayName;

	private MetricType metricType = MetricType.GAUGE;

	private int persistPeriod = -1;

	@Nullable
	private String persistPolicy;

	@Nullable
	private String unit;


	/**
	 * The category of this metric (ex. throughput, performance, utilization).
	 */
	/**
	 *此度量的类别（例如吞吐量、性能、利用率）。
	 */
	public void setCategory(@Nullable String category) {
		this.category = category;
	}

	/**
	 * The category of this metric (ex. throughput, performance, utilization).
	 */
	/**
	 *此度量的类别（例如吞吐量、性能、利用率）。
	 */
	@Nullable
	public String getCategory() {
		return this.category;
	}

	/**
	 * A display name for this metric.
	 */
	/**
	 *此度量的显示名称。
	 */
	public void setDisplayName(@Nullable String displayName) {
		this.displayName = displayName;
	}

	/**
	 * A display name for this metric.
	 */
	/**
	 *此度量的显示名称。
	 */
	@Nullable
	public String getDisplayName() {
		return this.displayName;
	}

	/**
	 * A description of how this metric's values change over time.
	 */
	/**
	 *此度量值如何随时间变化的描述。
	 */
	public void setMetricType(MetricType metricType) {
		Assert.notNull(metricType, "MetricType must not be null");
		this.metricType = metricType;
	}

	/**
	 * A description of how this metric's values change over time.
	 */
	/**
	 *此度量值如何随时间变化的描述。
	 */
	public MetricType getMetricType() {
		return this.metricType;
	}

	/**
	 * The persist period for this metric.
	 */
	/**
	 *此度量的持续时间。
	 */
	public void setPersistPeriod(int persistPeriod) {
		this.persistPeriod = persistPeriod;
	}

	/**
	 * The persist period for this metric.
	 */
	/**
	 *此度量的持续时间。
	 */
	public int getPersistPeriod() {
		return this.persistPeriod;
	}

	/**
	 * The persist policy for this metric.
	 */
	/**
	 *此度量的持久化策略。
	 */
	public void setPersistPolicy(@Nullable String persistPolicy) {
		this.persistPolicy = persistPolicy;
	}

	/**
	 * The persist policy for this metric.
	 */
	/**
	 *此度量的持久化策略。
	 */
	@Nullable
	public String getPersistPolicy() {
		return this.persistPolicy;
	}

	/**
	 * The expected unit of measurement values.
	 */
	/**
	 *预期的计量单位值。
	 */
	public void setUnit(@Nullable String unit) {
		this.unit = unit;
	}

	/**
	 * The expected unit of measurement values.
	 */
	/**
	 *预期的计量单位值。
	 */
	@Nullable
	public String getUnit() {
		return this.unit;
	}

}
